const baseUrl = '/activity'
import request from '@/utils/request'
/** 获取活动列表
 * @param {Object} params 查询参数
 * @returns {Promise} 活动列表
 */
export const getActivityList = (params) => {
    return request({
        url: `${baseUrl}/list`,
        method: 'get',
        params
    })
}


/**
 * 获取当前教师活动列表
 * @param {} params 
 * @returns 
 */
export const getCurrnetUserActivityList = (params) => {
    return request({
        url: `${baseUrl}/getCurrent/list`,
        method: 'get',
        params
    })
}


/**
 * 发布活动
 */

export const publishActivity = (data) => {
    return request({
        url: `${baseUrl}/publish`,
        method: 'post',
        data
    })
}


// 获取活动详情
export const getActivityDetail = (id) => {
    return request({
        url: `${baseUrl}/detail/${id}`,
        method: 'get'
    })
}

// 更新活动
export const updateActivity = (data) => {
    return request({
        url: `${baseUrl}/update`,
        method: 'put',
        data
    })
}


// 删除活动
export const deleteActivity = (id) => {
    return request({
        url: `${baseUrl}/delete/${id}`,
        method: 'delete'
    })
}


// 报名活动
export const registerActivity = (id) => {
    return request({
        url: `${baseUrl}/signUp/${id}`,
        method: 'post',
    })
}


// 取消报名活动
export const cancelRegisterActivity = (id) => {
    return request({
        url: `${baseUrl}/cancelSignUp/${id}`,
        method: 'PUT',
    })
}


// 导出参与者名单
export const exportParticipantsList = (activityId) => {
    return request({
        url: `${baseUrl}/export/participate/${activityId}`,
        method: 'GET',
        responseType: 'blob', 
        headers: {
            'Accept': 'application/vnd.ms-excel'
        }
    })
}


// 获取学生自己的报名信息
export const getStudentList = (params) => {
    return request({
        url: `${baseUrl}/getStudent/list`,
        method: 'GET',
        params
    })
}

// 学生签到
export const checkInActivity = (activityId) => {
    return request({
        url: `${baseUrl}/checkIn/${activityId}`,
        method: 'POST'
    })
}